<template>
    <span>
        <a href="" @click.stop.prevent="testJob()">执行</a>&nbsp;
        <a href="" @click.stop.prevent="resumeJob()">恢复</a>&nbsp;
        <a href="" @click.stop.prevent="pauseJob()">暂停</a>&nbsp;
        <a href="" @click.stop.prevent="deleteJob()">删除</a>&nbsp;
    </span>
</template>

<script>
    export default {
        name: "TaskTable",
        props: {
            rowData: {
                type: Object
            },
            field: {
                type: String
            },
            index: {
                type: Number
            }
        },
        methods: {
            testJob() {
                this.$axiosPost('/testJob.action', {'id': this.rowData.id}).then((res) => {
                    if (res.data === true) {
                        // 参数根据业务场景随意构造
                        let params = {type: 'testJob'};
                        this.$emit('on-custom-comp', params);
                    }
                }).catch((res) => {
                    console.error(res)
                    this.$message.error('失败')
                })
            },

            resumeJob() {
                this.$axiosPost('/resumeJob.action', {'id': this.rowData.id}).then((res) => {
                    debugger
                    if (res.data === true) {
                        // 参数根据业务场景随意构造
                        let params = {type: 'resumeJob'};
                        this.$emit('on-custom-comp', params);
                    }
                }).catch((res) => {
                    console.error(res)
                    this.$message.error('失败')
                })

            },
            pauseJob() {
                this.$axiosPost('/pauseJob.action', {'id': this.rowData.id}).then((res) => {
                    if (res.data === true) {
                        // 参数根据业务场景随意构造
                        let params = {type: 'pauseJob'};
                        this.$emit('on-custom-comp', params);
                    }
                }).catch((res) => {
                    console.error(res)
                    this.$message.error('失败')
                })


            },
            deleteJob() {

                this.$axiosPost('/deleteJob.action', {'id': this.rowData.id}).then((res) => {
                    if (res.data === true) {
                        // 参数根据业务场景随意构造
                        let params = {type: 'deleteJob'};
                        this.$emit('on-custom-comp', params);
                    }
                }).catch((res) => {
                    console.error(res)
                    this.$message.error('失败')
                })
            }
        }
    }
</script>

<style>

</style>